package com.woniu.woniuproject.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.woniuproject.entity.Account_log;
import com.woniu.woniuproject.mapper.Account_logMapper;
import com.woniu.woniuproject.mapper.moneyCountMapper;
import com.woniu.woniuproject.vo.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * 功能描述:<br>
 * 〈〉
 *
 * @author EDZ
 * @create 2020/11/17
 * @since 1.0.0
 */
@Service
public class systemService {

    @Autowired
    Account_logMapper account_logMapper;
    @Autowired
    moneyCountMapper moneyCountMapper;
    public int sysinsert(int Pid,String type,Double debtMoney){
        Double money=moneyCountMapper.selectmoney();
        Account_log account_log = new Account_log();
        account_log.setAmainaccountid(1);
        account_log.setPid(Pid);
        account_log.setAreceiveorpay("付款");
        account_log.setAtransferserialno(new Date().getTime()+ UUID.randomUUID().toString().substring(0,3));
        account_log.setAdate(new Date());
        account_log.setAtype(type);
        account_log.setAamount(debtMoney);
        account_log.setAbeforetradingmoney(money);
        account_log.setAaftertradingmoney(money-debtMoney);
        return account_logMapper.sysinsert(account_log);
    };

    public PageInfo<Account_log> queryeryall(Page page, Date startDate, Date endDate) {
        PageHelper.startPage(page.getNowPage(),page.getMaxPage());
        List<Account_log> looseLabels = account_logMapper.selectByAplay(startDate, endDate);
        PageInfo<Account_log> info = new PageInfo<>(looseLabels);
        return info;
    }

}